<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>函数求阶乘</title>
</head>

<body>
    <script>
        function getJC(n) {
            var num = 1;
            for (var i = 2; i <= n; i++) {
                num = num * i;
            }
            return num;
        }

        function getSum(n) {
            var sum = 0;
            for (var i = 1; i <= n; i++) {
                sum = sum + getJC(i);
            }
            return sum;
        }
        var n = prompt('请输入n的值');
        console.log(n + '的阶乘是' + getJC(n));
        console.log(n + '的阶乘累加和是' + getSum(n));
    </script>
</body>

</html>